package com.gedmanager.qrcode;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class ProductCreator {

	long id = 0;
	String text;
	Double price;

	public ProductCreator(long id, String text, Double price) {
		super();
		this.id = id;
		this.text = text;
		this.price = price;
	}
	public long getId() {
		return id;
	}
	public void setId(long id) {
		this.id = id;
	}
	public String getText() {
		return text;
	}
	public void setText(String text) {
		this.text = text;
	}
	public Double getPrice() {
		return price;
	}
	public void setPrice(Double price) {
		this.price = price;
	}

	@SuppressWarnings({ })
	@Override
	public String toString() {
		@SuppressWarnings("unused")
		JSONObject obj = new JSONObject();
		
		JSONArray array = new JSONArray();
		
		JSONObject external = new JSONObject();
		JSONObject internal = new JSONObject();
		try {
			internal.put("id", "" + this.id);
			internal.put("text", this.text);
			internal.put("price", "" + this.price);
		} catch (JSONException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		
		array.put(internal);
		try {
			external.put("item", array);
		} catch (JSONException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		
		System.out.print(external);
//		
//		Map m1 = new LinkedHashMap();
//		m1.put("id", this.id);
//		m1.put("text", this.text);
//		m1.put("price",this.price);
//
//		LinkedList  l1 = new LinkedList();
//		l1.add(m1);
//		
//		try {
//			obj.put("item", l1);
//		} catch (JSONException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
		return external.toString();
	}

}
